package top.sunpxit.generator.primary;

import lombok.AccessLevel;
import lombok.Data;
import lombok.Setter;
import top.sunpxit.generator.util.StringUtils;

/**
 * @program: set-sail-generator
 * @description:
 * @author: sunpx
 * @create: 2021-03-26 15:14
 **/
@Data
public class FieldEntity {

    /**
     * 数据类型
     */
    private String columnType;
    /**
     * 是否允许为空
     */
    private boolean isNullable;

    /**
     * 注释
     */
    private String columnComment;

    /**
     *
     */
    private String ordinalPosition;


    /**
     * 是否为主键
     */
    private boolean columnKey;
    /**
     * 字段名称
     */
    private String columnName;

    /**
     * 表名
     */
    private String tableName;

    public void setNullable(String nullable) {
        this.isNullable = !nullable.equals("true");
    }


    public void setColumnKey(String columnKey) {
        this.columnKey = !StringUtils.isEmpty(columnKey);
    }

    public void setColumnType(String columnType) {
        this.columnType = StringUtils.toSqlToJava(columnType);
    }

    public void setColumnName(String columnComment) {
        this.columnName = StringUtils.toCamelCase(columnComment);
    }
}
